package cn.edu.scau.dao;

import cn.edu.scau.entity.LiveInRegister;
import org.apache.ibatis.jdbc.SQL;

public class LiveInRegisterSqlProvider {

    public String insertSelective(LiveInRegister record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("liveinregister");
        
        if (record.getCustomerid() != null) {
            sql.VALUES("customerID", "#{customerid,jdbcType=INTEGER}");
        }
        
        if (record.getBookingid() != null) {
            sql.VALUES("bookingID", "#{bookingid,jdbcType=INTEGER}");
        }
        
        if (record.getBedid() != null) {
            sql.VALUES("bedID", "#{bedid,jdbcType=INTEGER}");
        }
        
        if (record.getLiveindate() != null) {
            sql.VALUES("liveinDate", "#{liveindate,jdbcType=DATE}");
        }
        
        if (record.getExpectedliveoutdate() != null) {
            sql.VALUES("expectedLiveoutDate", "#{expectedliveoutdate,jdbcType=DATE}");
        }
        
        if (record.getActuallyliveoutdate() != null) {
            sql.VALUES("actuallyLiveoutDate", "#{actuallyliveoutdate,jdbcType=DATE}");
        }
        
        if (record.getRegisteruseflag() != null) {
            sql.VALUES("registerUseflag", "#{registeruseflag,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LiveInRegister record) {
        SQL sql = new SQL();
        sql.UPDATE("liveinregister");
        
        if (record.getLiveindate() != null) {
            sql.SET("liveinDate = #{liveindate,jdbcType=DATE}");
        }
        
        if (record.getExpectedliveoutdate() != null) {
            sql.SET("expectedLiveoutDate = #{expectedliveoutdate,jdbcType=DATE}");
        }
        
        if (record.getActuallyliveoutdate() != null) {
            sql.SET("actuallyLiveoutDate = #{actuallyliveoutdate,jdbcType=DATE}");
        }
        
        if (record.getRegisteruseflag() != null) {
            sql.SET("registerUseflag = #{registeruseflag,jdbcType=BIT}");
        }
        
        sql.WHERE("customerID = #{customerid,jdbcType=INTEGER}");
        sql.WHERE("bookingID = #{bookingid,jdbcType=INTEGER}");
        sql.WHERE("bedID = #{bedid,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}